package com.alks.function.controller;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.RoleCheck;
import com.alks.common.aop.WebLogger;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.data.request.MpPurDisRequest2;
import com.alks.function.service.MpPurDisService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import javax.servlet.http.HttpServletResponse;

@ApiRestController("/MaterialOrder")
@Api(tags = "材料请购查询")
@Slf4j
@RoleCheck(prgIds = {"100407","110302","140202","150204","160202","170504","180705","190202","210202"})
public class MpPurDisController {

    @Autowired
    private MpPurDisService mpPurDisService;

    @WebLogger
    @PostMapping("/getOrderDetail")
    @ApiOperation("材料订购明细")
    public ResponseInfo getOrderDetail(@RequestBody MpPurDisRequest2 request){
        return mpPurDisService.getOrderDetails(request);
    }

    @WebLogger
    @GetMapping("/getOrderCondition")
    @ApiOperation("查询条件返回")
    public ResponseInfo getOrderCondition(){
        return mpPurDisService.getOrderCondition();
    }

    @WebLogger
    @PostMapping("/exportMpPurDis")
    @ApiOperation("按查询导出明细")
    public void exportMpPurDis(@RequestBody MpPurDisRequest2 request, HttpServletResponse response){
        mpPurDisService.exportMpPurDis(request,response);
    }
}
